package com.wp.module.wpUserDetail.controller;

import com.wp.common.annotation.Log;
import com.wp.common.core.controller.BaseController;
import com.wp.common.core.domain.AjaxResult;
import com.wp.common.core.page.TableDataInfo;
import com.wp.common.enums.BusinessType;
import com.wp.common.utils.poi.ExcelUtil;
import com.wp.module.wpUserDetail.domain.WpUserDetail;
import com.wp.module.wpUserDetail.service.IWpUserDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户互动信息Controller
 * 
 * @author wp
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/module/wpUserDetail")
public class WpUserDetailController extends BaseController
{
    @Autowired
    private IWpUserDetailService wpUserDetailService;

    /**
     * 查询用户互动信息列表
     */
    @PreAuthorize("@ss.hasPermi('module:wpUserDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(WpUserDetail wpUserDetail)
    {
        startPage();
        List<WpUserDetail> list = wpUserDetailService.selectWpUserDetailList(wpUserDetail);
        return getDataTable(list);
    }

    /**
     * 导出用户互动信息列表
     */
    @PreAuthorize("@ss.hasPermi('module:wpUserDetail:export')")
    @Log(title = "用户互动信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WpUserDetail wpUserDetail)
    {
        List<WpUserDetail> list = wpUserDetailService.selectWpUserDetailList(wpUserDetail);
        ExcelUtil<WpUserDetail> util = new ExcelUtil<WpUserDetail>(WpUserDetail.class);
        util.exportExcel(response, list, "用户互动信息数据");
    }

    /**
     * 获取用户互动信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:wpUserDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(wpUserDetailService.selectWpUserDetailById(id));
    }

    /**
     * 新增用户互动信息
     */
    @PreAuthorize("@ss.hasPermi('module:wpUserDetail:add')")
    @Log(title = "用户互动信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WpUserDetail wpUserDetail)
    {
        return toAjax(wpUserDetailService.insertWpUserDetail(wpUserDetail));
    }

    /**
     * 修改用户互动信息
     */
    @PreAuthorize("@ss.hasPermi('module:wpUserDetail:edit')")
    @Log(title = "用户互动信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WpUserDetail wpUserDetail)
    {
        return toAjax(wpUserDetailService.updateWpUserDetail(wpUserDetail));
    }

    /**
     * 删除用户互动信息
     */
    @PreAuthorize("@ss.hasPermi('module:wpUserDetail:remove')")
    @Log(title = "用户互动信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wpUserDetailService.deleteWpUserDetailByIds(ids));
    }
}
